package com.zhoug.zmui3demo.ui;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

/**
 * @Author 35574
 * @Date 2021/2/22
 * @Description
 */
public class TextCanvasView extends View {
    private Paint mPaint;

    public TextCanvasView(Context context) {
        this(context,null);
    }

    public TextCanvasView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public TextCanvasView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setStyle(Paint.Style.FILL);
        mPaint.setColor(Color.RED);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.save();
        canvas.translate(0,0);
        canvas.drawCircle(getWidth() >> 1, getHeight() >> 1, Math.min(getWidth(), getHeight()) >> 2,mPaint);
        canvas.restore();
    }

}
